#ifndef MOVEBUTTON_H
#define MOVEBUTTON_H

#include <QPushButton>
#include <QPropertyAnimation>

class MoveButton : public QPushButton
{
    Q_OBJECT
    Q_PROPERTY(int value WRITE setValue)

public:
public:
    MoveButton(QWidget *parent = nullptr);

    void setSize(QSize size);
    void setBuddy(QWidget *buddy);
public slots:
    void setExtended(bool value);
signals:
    void extend();
    void retract();
    void extended(bool);
protected:
    void paintEvent(QPaintEvent *event);
    void enterEvent(QEnterEvent *event);
    void leaveEvent(QEvent *event);
    bool eventFilter(QObject *watched, QEvent *event);
private:
    void setValue(int value);
    void updateFrame();
private slots:
    void clicked();
    void moveButton();
    void animationFinished();
private:
    QSize m_size{20, 70};
    bool m_extended{true};
    bool m_hovered{false};
    QWidget *m_buddy{nullptr};

    QPropertyAnimation m_animation;
    int m_buddyWidth;
    QSize m_minSize;
    QSize m_maxSize;

    QList<QPointF> m_border;
    QList<QPointF> m_extendDirect;
    QList<QPointF> m_retractDirect;
};

#endif // MOVEBUTTON_H
